package com.ruoyi.cmenonmetal.controller;

import com.ruoyi.cmenonmetal.domain.ZxNonmetalOrderForm;
import com.ruoyi.cmenonmetal.service.IZxNonmetalOrderFormService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * NonmetalOrderController
 * 
 * @author zhangxu
 * @date 2021-12-16
 */
@RestController
@RequestMapping("/Nonmetal/NonmetalOrder")
public class ZxNonmetalOrderFormController extends BaseController
{
    @Autowired
    private IZxNonmetalOrderFormService zxNonmetalOrderFormService;

    /**
     * 查询NonmetalOrder列表
     */
    @PreAuthorize("@ss.hasPermi('Nonmetal:NonmetalOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxNonmetalOrderForm zxNonmetalOrderForm)
    {
        startPage();
        List<ZxNonmetalOrderForm> list = zxNonmetalOrderFormService.selectZxNonmetalOrderFormList(zxNonmetalOrderForm);
        return getDataTable(list);
    }

    /**
     * 导出NonmetalOrder列表
     */
    @PreAuthorize("@ss.hasPermi('Nonmetal:NonmetalOrder:export')")
    @Log(title = "NonmetalOrder", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxNonmetalOrderForm zxNonmetalOrderForm)
    {
        List<ZxNonmetalOrderForm> list = zxNonmetalOrderFormService.selectZxNonmetalOrderFormList(zxNonmetalOrderForm);
        ExcelUtil<ZxNonmetalOrderForm> util = new ExcelUtil<ZxNonmetalOrderForm>(ZxNonmetalOrderForm.class);
        util.exportExcel(response, list, "NonmetalOrder数据");
    }

    /**
     * 获取NonmetalOrder详细信息
     */
    @PreAuthorize("@ss.hasPermi('Nonmetal:NonmetalOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zxNonmetalOrderFormService.selectZxNonmetalOrderFormById(id));
    }

    /**
     * 新增NonmetalOrder
     */
    @PreAuthorize("@ss.hasPermi('Nonmetal:NonmetalOrder:add')")
    @Log(title = "NonmetalOrder", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxNonmetalOrderForm zxNonmetalOrderForm)
    {
        return toAjax(zxNonmetalOrderFormService.insertZxNonmetalOrderForm(zxNonmetalOrderForm));
    }

    /**
     * 修改NonmetalOrder
     */
    @PreAuthorize("@ss.hasPermi('Nonmetal:NonmetalOrder:edit')")
    @Log(title = "NonmetalOrder", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZxNonmetalOrderForm zxNonmetalOrderForm)
    {
        return toAjax(zxNonmetalOrderFormService.updateZxNonmetalOrderForm(zxNonmetalOrderForm));
    }

    /**
     * 删除NonmetalOrder
     */
    @PreAuthorize("@ss.hasPermi('Nonmetal:NonmetalOrder:remove')")
    @Log(title = "NonmetalOrder", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zxNonmetalOrderFormService.deleteZxNonmetalOrderFormByIds(ids));
    }
}
